 

/* INSTRUCTION: This is a command line application. So please execute this template with the following arguments:

		arg[0] = username
		arg[1] = password
*/

/**
 * @author (Your Name Here)
 *
 */
 
import com.google.gdata.client.authn.oauth.GoogleOAuthParameters;
import com.google.gdata.client.authn.oauth.OAuthException;
import com.google.gdata.client.authn.oauth.OAuthHmacSha1Signer;
import com.google.gdata.client.calendar.CalendarService;
import com.google.gdata.data.acl.AclEntry;
import com.google.gdata.data.acl.AclScope;
import com.google.gdata.data.calendar.CalendarAclRole;
import com.google.gdata.data.calendar.CalendarEntry;
import com.google.gdata.data.calendar.CalendarFeed;
import com.google.gdata.util.AuthenticationException;
import com.google.gdata.util.ServiceException;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

/**
 * This is a test template
 */

  public class Calendar {
    
    public static void main(String[] args) throws OAuthException {
      
      try {
       	      String account="1_art";
              String CONSUMER_KEY="montfortperungudi.edu.in";
              
       	       GoogleOAuthParameters oauthParam=new GoogleOAuthParameters();
        	   oauthParam.setOAuthConsumerKey("montfortperungudi.edu.in");
        	   oauthParam.setOAuthConsumerSecret("tUsE7wcEKY65IpUCsTc4E5T9");
        	   oauthParam.setScope("http://www.google.com/calendar/feeds/");
        	   
        	   CalendarService service=new CalendarService("calendar");
       	       service.setOAuthCredentials(oauthParam,new OAuthHmacSha1Signer());
       	       
       	       AclEntry entry = new AclEntry();
          	   URL aclUrl1=new URL("http://www.google.com/calendar/feeds/montfortperungudi.edu.in_k93ua67i9blu9u18jbvgimprnk@group.calendar.google.com/acl/full"+"?xoauth_requestor_id="+account+"@"+CONSUMER_KEY);
          	   entry.setScope(new AclScope(AclScope.Type.USER, "aagash.sakthivel@montfortperungudi.edu.in"));
            	entry.setRole(CalendarAclRole.READ);

              AclEntry ae=service.insert(aclUrl1,entry);
      }
      catch(AuthenticationException e) {
        e.printStackTrace();
      }
      catch(MalformedURLException e) {
        e.printStackTrace();
      }
      catch(ServiceException e) {
        e.printStackTrace();
      }
      catch(IOException e) {
        e.printStackTrace();
      }
    }
  }
